home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan
/
Opus 5 - Magellan.iso
/
Extras
/
Install_3.3
/
ARexx
/
Install_Execute.dopus5
next >
Wrap
Text File
|
1997-05-09
|
4KB
|
150 lines
/* $VER: Install_Execute.dopus5 3.1 (09.05.97) © Frédéric Steinfels
*/
signal on BREAK_C
signal on BREAK_D
signal on BREAK_E
signal on BREAK_F
signal on HALT
signal on IOERR
signal on SYNTAX
signal on FAILURE
options failat 21
options results
parse arg arguments
ProgramName = "Install_Execute.dopus5";
ArgsTemplate = "PORT/A,MNPORT/A,MYPORT/A,MYID/A,SRCP/A,DSTP/A"
lf='0a'x
if strip(arguments) = '?' then do
Call WriteCh(STDOUT, ArgsTemplate || ': ')
pull arguments
end; else nop
if ~ReadArgs(arguments,ArgsTemplate) then do
say Fault(RC,ProgramName)
exit 10
end; else nop
drop arguments
catalog=opencatalog('Install.dopus5.catalog','english',0)
address value PORT
MYPORTH=openport(MYPORT)
do until CMD='0'
call waitpkt(MYPORT)
Packet=getpkt(MYPORT)
if Packet ~= null() then do
ln = getarg(Packet,0)
ID=substr(ln,1,1)
CMD=substr(ln,2,1)
ARG=substr(ln,3)
call CheckArg
IF ID=0 THEN DO
IF CMD=1 THEN DO
parse var arg path '0a'x file
dst=makepath(dstp,path)
Call CheckExDir
command wait copy quiet '"' || makepath(makepath(srcp,path),file) || '" "' || makepath(dstp,path) || '"'
end
IF CMD=2 THEN DO
parse var arg path '0a'x file
dst=makepath(dstp,path)
Call CheckExDir
command wait copy quiet '"' || makepath(makepath(dstp,path),file) || '" "' || makepath(srcp,path) || '"'
end
end
IF ID=6 THEN DO
IF CMD=1 THEN DO
parse var arg path '0a'x file
command wait delete quiet '"' || makepath(makepath(dstp,path),file) || '"'
dst=makepath(dstp,path)
Call CheckExDir
command wait copy quiet '"' || makepath(makepath(srcp,path),file) || '" "' || makepath(dstp,path) || '"'
end
IF CMD=2 THEN DO
parse var arg path '0a'x file
command wait delete quiet '"' || makepath(makepath(srcp,path),file) || '"'
dst=makepath(dstp,path)
Call CheckExDir
command wait copy quiet '"' || makepath(makepath(dstp,path),file) || '" "' || makepath(srcp,path) || '"'
end
end
end
end
Call CleanUP
exit
CheckExDir:
if exists(dst) then return
parse var dst dst2 '/' rest
do until exists(dst)
if ~exists(dst2) then do
command wait makedir noicon '"' || dst2 || '"'
end
parse var rest new '/' rest
dst2=dst2 || '/' || new
end
return
CheckArg:
IF DATATYPE(ID)~='NUM' | DATATYPE(CMD)~='NUM' THEN Call CheckArgFail
IF ID=0 & CMD<3 THEN return
IF ID=6 & CMD<3 THEN return
Call CheckArgFail
RETURN
CheckArgFail:
address value PORT
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(52,'Invalid packet received') || lf || 'ID=' || ID || lf || 'CMD=' || CMD || lf || 'ARG=' || ARG || '"' GetCatStr(0,'Abort')
Call CleanUP
exit
ERROR:
HALT:
IOERR:
SYNTAX:
IF RC ~= 0 THEN DO
line=sigl
text=errortext(rc)
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || text || lf || GetCatStr(19,'Line') line || '"' GetCatStr(0,'Abort')
END
else do
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || '"' GetCatStr(0,'Abort')
end
BREAK_C:
BREAK_D:
BREAK_E:
BREAK_F:
Call CleanUP
exit
CleanUp:
dopus send MNPORT MYID || 0
if POS(MYPORT,SHOW('p'))~=0 then do
Call FORBID()
Call ClosePort(MYPORTH)
Call PERMIT()
end
Call CloseCatalog(catalog)
return
getcatstr: /* Thank you for this procedure, Edmund */
parse arg msgno,msgstring
if catalog~=0 then
msgstring=getcatalogstr(catalog,msgno,msgstring)
do i=3 to arg()
parse var msgstring fore '%s' aft
msgstring=fore||arg(i)||aft
end
return msgstring